package com.project.controller;

import com.project.bean.UserBean;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.util.Arrays;
import java.util.List;

@RestController
@RequestMapping("ajax")
public class AjaxController {
    @RequestMapping("/checkName")
    public String checkName(String name){
        if("java".equals(name)){
            return "no";
        }
        else{
            return "ok";
        }
    }

    @RequestMapping("/getUser")
    public UserBean getObj(){
        return new UserBean(1, "朱元章",
                "18993026038", LocalDate.parse("1998-02-03"));
    }

    @RequestMapping("/findAll")
    public List<UserBean> getList(){
        return Arrays.asList(
                new UserBean(1, "朱元章",
                        "18993026038", LocalDate.parse("1998-02-03")),
               new UserBean(8, "胡强",
                         "13029382932", LocalDate.parse("1988-03-18")),
                new UserBean(5, "刘勇",
                           "13396847434", LocalDate.parse("1998-08-09")
        ));
    }
}
